#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,V,d[100010],v[100010],a[100010],p[100010],c,b;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        cin>>n>>m>>L>>V;
        for(int j=1;j<=n;j++)
        {
            cin>>d[j]>>v[j]>>a[j];
        }
        for(int j=1;j<=m;j++) cin>>p[j];
    }
    b+=m;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            if(v[i]>V)
            {
                c+=1;
                b-=1;
            }
        }
        else if(v[i]+a[i]*p[i]>V)
        {
            c+=1;
            b-=1;
        }
    }
    cout<<c<<" "<<b;
    return 0;
}
